<?
if (!defined('MODULE_FILE')){
	die ("cant access file directly!");
}

$mid 	= ( ( true == isset( $_GET['mid'] ) && true == valStr( $_GET['mid'] ) ) ? $_GET['mid'] : NULL );
$smid 	= ( ( true == isset( $_GET['smid'] ) && true == valStr( $_GET['smid'] ) ) ? $_GET['smid'] : NULL );

autoLoader();

$objBaseChargeCatagories 	= new BaseChargeCatagories();
$objChargeCatagories 	= new ChargeCatagories();
?>
<html>
<head>
<?php require_once 'commonJS.php'; ?>
</head>
<body>
	<div style="margin-left:12px; margin-top: 10px;">
		<p>
			<a class="btn btn-outline btn-primary btn-xs" id="act" href="modules.php?file=charge_catagories&mid=<? echo $mid;?>&smid=<? echo $smid;?>" >Add Charge Catagory</a>
			<a class="btn btn-outline btn-primary btn-xs" id="active" href="modules.php?file=view_charge_catagories&type=view&mid=<? echo $mid;?>&smid=<? echo $smid;?>" >View All Charges Catagories</a>&nbsp;
		</p>
	</div>
<div class="col-lg-8">
<div class="panel panel-primary">
<div class="panel-heading"><i class="fa fa-bell fa-fw"></i> Charge Catagories</div>
<div class="panel-body">
	<form METHOD="POST" action="modules.php?file=insert_charge_catagories&type=insert&mid=<? echo $mid; ?>&smid=<? echo $smid; ?>" id="formSubmit" name="formSubmit" >
		<?php
		$intChargeCatId = NULL;
		$strName 			= NULL;
		$strDescription 	= NULL;
		$boolIsPublished 	= true;
		$intOrderNumber 	= NULL;
				
		if( true == isset( $_GET['charge_cat_id'] ) && true == valStr( $_GET['charge_cat_id'] ) ) {
			$intChargeCatId = $_GET['charge_cat_id'];
			
			$objBaseChargeCatagories = $objChargeCatagories->fetchChargeCatagoriesById( $_GET['charge_cat_id'] );
			
			if( true == valObj( $objBaseChargeCatagories, 'BaseChargeCatagories' ) ) {
				$strName 				= $objBaseChargeCatagories->getName();
				$strDescription 		= $objBaseChargeCatagories->getDescription();
				$boolIsPublished 		= $objBaseChargeCatagories->getIsPublished();
				$intOrderNumber 		= $objBaseChargeCatagories->getOrderNumber();
			}
		} else if( true == valObj( $objBaseChargeCatagories, 'BaseChargeCatagories' ) ) {
			$intChargeCatId = $objBaseChargeCatagories->fetchNextId();
		}
		?> 
    
	
		<table width="80%" cellspacing="0" cellpadding="3">
			<tr><td height="10" colspan="2"><input id="charge_cat_id" Name="charge_cat_id" type="hidden"  style="width:100px;"  value="<?php echo $intChargeCatId;?>"></td></tr>
            <tr valign="top">
				<td  width="220">Name</td>
				<td><input id="name" Name="name" type="text" class="validate[required]" value="<?php echo $strName; ?>" style="width:202px;"></td>
			</tr>
			<tr>
				<td colspan="2" height="10px"></td>
			</tr>
			  <tr valign="top">
				<td  width="220">Description</td>
				<td><textarea name="description" rows="5" cols="40"><?php echo $strDescription; ?></textarea></td>
			</tr>
			<tr>
				<td colspan="2" height="10px"></td>
			</tr>
			<tr valign="top">
				<td  width="220">Is Published</td>
				<td><input id="is_published" Name="is_published" type="text" class="validate[required]" value="<?php echo $boolIsPublished; ?>" style="width:202px;"></td>
			</tr>
			<tr>
				<td colspan="2" height="10px"></td>
			</tr>
			 <tr valign="top">
				<td  width="200px">Order Number</td>
				<td><input id="order_number" Name="order_number" type="text" class="validate[required]" value="<?php echo $intOrderNumber; ?>" style="width:202px;"></td>
			</tr>
			
			<tr>
				<td colspan="2" height="10px"></td>
			</tr>
			<tr valign="top">
				<td class="mandatory" width="220">&nbsp;</td>
				<td>
				<?php
						if( true == isset( $_GET['charge_cat_id'] ) && true == valStr( $_GET['charge_cat_id'] ) ) {
							echo "<input type=hidden name=operation value=update>";
							echo "<input type=submit value=UPDATE id=Submit name=Submit>";
						} else {
							echo "<input type=hidden name=operation value=insert>";
							echo "<input type=submit value=SUBMIT id=Submit name=Submit>";
						}
					?>
				
				</td> 				
			</tr>
		</table>
</div>
</div>
</div>	
</form>
</body>
</html>